﻿using Sunny.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MesBSW.View.Dialog.Mes
{
    public partial class UpdateProdLineDia : UIEditForm
    {
        private Hashtable _line_hs = new Hashtable();
        private List<string> _dir_list = new List<string>();
        private List<string> _all_list = new List<string>();

        public Hashtable LineHs { get { return _line_hs; } }

        public UpdateProdLineDia(List<string> directList,List<string> sourceList)
        {
            InitializeComponent();
            this._dir_list = directList;
            this._all_list = sourceList;
        }

        private void UpdateProdLineDia_Load(object sender, EventArgs e)
        {
            this.sou_line_dgv1.DataSource = this._all_list;
            if (this._dir_list != null && this._dir_list.Count > 0)
            { 
                DataTable tmpDt = new DataTable();
                tmpDt.Columns.Add("dir_line");
                tmpDt.Columns.Add("sou_line");

                foreach (var tmpStr in this._dir_list)
                {
                    DataRow dr = tmpDt.NewRow();
                    dr["dir_line"] = tmpStr;
                    tmpDt.Rows.Add(dr);
                }

                this.dgvLine.DataSource = tmpDt;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.dgvLine.EndEdit();
            if (this.dgvLine.DataSource != null)
            {
                DataTable tmpDt = this.dgvLine.DataSource as DataTable;
                this._line_hs = new Hashtable();
                foreach (DataRow dr in tmpDt.Rows)
                {
                    this._line_hs.Add(dr["dir_line"].ToString(), dr["sou_line"].ToString());
                }
            }
        }
    }
}
